FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine as src
WORKDIR /app
COPY projectfiles.tar .
RUN tar -xvf projectfiles.tar
RUN dotnet restore -v q --configfile ./nuget.config
COPY . .

FROM src as publish
RUN cd /app/src/Leo.Core.Gateway.HttpApi.Host
RUN dotnet publish --no-restore -c Release --nowarn:NU1604,NU1602,AD001 -o /app/published-app

FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine as runtime
WORKDIR /app
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add --no-cache icu-libs
COPY --from=publish /app/published-app .
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV ASPNETCORE_URLS "http://*:5003"
ENV ASPNETCORE_ENVIRONMENT "Staging"
ENTRYPOINT ["dotnet", "Leo.Core.Gateway.HttpApi.Host.dll"]
